package org.example.DesignPatterns.Command;

import java.util.Arrays;

/**
 * @description:
 * @author: farprt
 * @create: 2022-09-24 10:58
 **/
public class Client {

    public static void main(String[] args) throws InterruptedException {
        Switcher switcher=new Switcher();
        Bulb bulb=new Bulb();
        Command switchCommand=new SwitchCommand(bulb);
//
//        switcher.setCommand(switchCommand);
//        switcher.buttonPush();
//        switcher.buttonPop();
//
//        Command flashCommand=new FlashCommand(bulb);
//        switcher.setCommand(flashCommand);
//        switcher.buttonPush();
//        Thread.sleep(3000);
//        switcher.buttonPop();

        Keyboard keyboard=new Keyboard();
        TV tv=new TV();
        Command tvOnCommand=new TVOnCommand(tv);
        Command tvOffCommand=new TVOffCommand(tv);
        Command tvChannelUpCommand=new TVChannelUpCommand(tv);

        keyboard.bindKeyCommand(
                Keyboard.KeyCode.F1,
                Arrays.asList(tvOnCommand)
        );

        keyboard.bindKeyCommand(
                Keyboard.KeyCode.LEFT,
                Arrays.asList(tvChannelUpCommand)
        );

        keyboard.bindKeyCommand(
                Keyboard.KeyCode.ESC,
                Arrays.asList(tvOffCommand)
        );

        keyboard.onKeyPressed(Keyboard.KeyCode.ESC);
        keyboard.onKeyPressed(Keyboard.KeyCode.F1);
        keyboard.onKeyPressed(Keyboard.KeyCode.LEFT);
        keyboard.onKeyPressed(Keyboard.KeyCode.F2);

        keyboard.bindKeyCommand(
                Keyboard.KeyCode.F2,
                Arrays.asList(
                        switchCommand,
                        tvOnCommand,
                        tvChannelUpCommand,
                        tvChannelUpCommand,
                        tvChannelUpCommand
                        )
        );

        keyboard.onKeyPressed(Keyboard.KeyCode.F2);


    }

}